﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
      
<ol class="breadcrumb">
    <li><a href="/Home/Home">Home</a></li>
    <li><a href="/Common/CommonIntoduction"> Sanelib Common</a></li>
    <li class="active">Infrastructure</li>
</ol>

 <div id="introduction">
     <h1 class="text-left">DataAccess</h1>
     <h4>IHealthViewRepository Interface</h4>
     <p>In the <b>IHealthViewRepository</b> defined to the <b>HealthView</b> type method which has returned to the array of record</p>
     <pre><code>
public interface IHealthViewRepository : IViewRepository&lt;HealthView&gt;
{
    HealthView[] HeathData();
}
</code></pre>
                <p>here, in the <b>IViewRepository</b> declare the methods and intializes into the <b>ViewRepository</b> of the <b>fetch</b> the record from the database.</p>
                <p>In the <b>HealthView</b> declare the Id, Type, HealthCheckDateTime see in the example and it's a View defined to common project into the <b>Views</b>.</p>
                <pre><code>
[TableName("Health")]
public class HealthView : IView
{
    public Guid Id { get; set; }
    public string Type { get; set; }
    public string Value { get; set; }
    [JsonIgnore]
    public DateTime? HealthCheckDateTime { get; set; }
    public string HealthCheckDateTimeString { get { return HealthCheckDateTime.GetValueOrDefault().ToString(CultureInfo.InvariantCulture); } }
}
</code></pre>
                <p>here, the <b>TableName</b> is the Attribute defined only for the <b>HealthTable</b></p>
            </div>
            <div id="start">
                <h4>HealthViewRepository Class</h4>
                <p>In the AuthnticationServices class implements a IHealthViewRepository interface and also inherits the <b>ViewRepository</b> class see in the example</p>
                <pre><code>
public class HealthViewRepository : ViewRepository&lt;HealthView&gt;, IHealthViewRepository
{
    public HealthView[] HeathData()
    {
        return Fetch(new Sql("Select top 60 * FROM HealthView  order by HealthCheckDateTime")).OrderByDescending(x=>x.Type).ThenByDescending(x=>x.HealthCheckDateTimeString).ToArray();
    }
}
</code></pre>
                <p>here, the <b>Fetch</b> is defined into the <b>ViewRepository</b> and select the first 60 records and returns to the <a href="../../Infrastructure/../../WebApp/ControllerApis/HealthController.html" class="btn-link">HealthController</a> of the Descending Order.</p>
            </div>
     